<?php
namespace app\backend\controller;
use think\Db;
use \think\Validate;
use think\Controller;
class Order extends Controller
{
	public function order_list()
    {
    	$ret=db('refund')->alias('a')->join('shopcart b','a.shopcart_id=b.shopcart_id')->join('product c','c.product_number=b.product_number')->where("refund_status=0")->select();
    	
    	$this->assign('ret',$ret);
    	
    	return view('order/order_list');

    }
    public function orderlist()
    {
    	$ret=db('order')->alias('a')->where("status=1")->select();
    	
    	$this->assign('ret',$ret);
    	
    	return view('order/orderlist');

    }
     public function order_delete()
    
    {
	    $order_id=input('get.order_id');
	    if($order_id!="")
	    {
	      $ret=db('order')->where("order_id={$order_id}")->delete();
	      if($ret==false)
	         {
	            $this->error('删除失败');
	          }
	             $this->success('删除成功');

	    }
    }
    public function refund_disagree()
    
    {
        $refund_id=input('get.refund_id');
        $shopcart_id=input('get.shopcart_id');
        if($refund_id!="")
        {
          $ret=db('refund')->where("refund_id={$refund_id}")->update(['refund_status'=>'1']);
          $result=db('shopcart')->alias('a')->join('refund b','a.shopcart_id=b.shopcart_id')->where("refund_id='{$refund_id}'")->update(['product_refund'=>'3']);
          if($ret==false)
             {
                $this->error('删除失败');
             }
                $this->success('删除成功');

        }
    }  
}